function showPager(line){
	if(line==undefined)
		line = getCurrentTabData().optionValueCheckout;
	else
		getCurrentTabData().optionValueCheckout = line;
	pager = new Pager(getCurrentTabData().tablePager, line);
	pager.init();
	
	pager.showPageNav('pager', getCurrentTabData().pageNavPosition);
	if(getCurrentTabData().pagerNumber!=undefined){
		pager.showPage(getCurrentTabData().pagerNumber);
		$("#"+getCurrentTabData().pagerNumberField).val(getCurrentTabData().pagerNumber);
	}else{
		pager.showPage(1);
		$("#"+getCurrentTabData().pagerNumberField).val(1);
	}
}
// Pager page
function Pager(tableName, itemsPerPage) {
	this.tableName = tableName;
	this.itemsPerPage = itemsPerPage;
	this.currentPage = 1;
	this.pages = 0;
	this.inited = false;
	this.showRecords = function (from, to) {
		var rows = document.getElementById(tableName).rows;
		for (var i = 1; i < rows.length; i++) {
			if (i < from+1 || i > to+1)
				rows[i].style.display = 'none';
			else
				rows[i].style.display = '';
			if($(rows[i]).attr("class")==getCurrentTabData().trCheck)
				to++;
		}
	}
	this.showPage = function (pageNumber) {
		getCurrentTabData().pagerNumber = pageNumber;
		if (! this.inited) {
			alert("not inited");
			return;
		}
		var oldPageAnchor = document.getElementById('pg'+this.currentPage);
		if(oldPageAnchor!=null){
			oldPageAnchor.className = 'linkWhite';
			this.currentPage = pageNumber;
			var newPageAnchor = document.getElementById('pg'+this.currentPage);
			newPageAnchor.className = 'pg-selected';
			var from = (pageNumber - 1) * itemsPerPage + 1;
			var to = from + parseInt(itemsPerPage) - 1;
			$('#'+getCurrentTabData().pagerNumberField+' option[value='+pageNumber+']').attr('selected', 'selected');///////
			this.showRecords(from, to);
		}
	}
	this.prev = function () {
		if (this.currentPage > 1)
			this.showPage(this.currentPage - 1);
	}
	this.prevFirst = function () {
			this.showPage(1);
	}
	this.next = function () {
		if (this.currentPage < this.pages) {
			this.showPage(this.currentPage + 1);
		}
	}
	this.init = function () {
		var rows = document.getElementById(tableName).rows;
		var sizeGroup = $("."+getCurrentTabData().trCheck).size();
		var records = ((rows.length-1)-(sizeGroup/2));
	
		getCurrentTabData().recordsPage = records;
		this.pages = Math.ceil(records / itemsPerPage);
		this.inited = true;
	}
	this.showPageNav = function (pagerName, positionId) {
		if (!this.inited) {
			alert("not inited");
			return;
		}
		var element = document.getElementById(positionId);
		var optionSetRow = [{"optionRow":10},{"optionRow":20},{"optionRow":30},{"optionRow":50},{"optionRow":100},{"optionRow":200},{"optionRow":'All'}]
		var RowpagerHtmlOption = "";
		for(var i =0;i<optionSetRow.length;i++){
			RowpagerHtmlOption += '<option id="row' + getCurrentTabData().functionGetData+i + '" class="link" value="'+optionSetRow[i].optionRow+'">' + optionSetRow[i].optionRow + '</option> ';
		}
		var prevSet = "";
		var prevSetAll = "";
		var pagerNumber = "";
		if(getCurrentTabData().pagerNumber!=undefined){
			pagerNumber = getCurrentTabData().pagerNumber;
		}else{
			pagerNumber = 1;
		}
		if(($("#pg1").attr("class")==undefined||$("#pg1").attr("class")=="pg-selected")&&getCurrentTabData().pagerNumber==undefined){
			prevSet = "";
			prevSetAll = "";
		}else{
			if(getCurrentTabData().valueDateCheckin!=undefined&&getCurrentTabData().valueDateCheckin!=""){
				prevSet = '<span onclick="' + pagerName + '.prev();'+getCurrentTabData().functionGetData+'(\'dateSearch\','+(parseInt(pagerNumber)-1)+');" class="linkWhite"> « Previos </span>';
				prevSetAll = '<span onclick="' + pagerName + '.prevFirst();'+getCurrentTabData().functionGetData+'(\'dateSearch\',1);" class="linkWhite"> « First </span>';
			}else{
				prevSet = '<span onclick="' + pagerName + '.prev();'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\','+(parseInt(pagerNumber)-1)+');" class="linkWhite"> « Previos </span>';
				prevSetAll = '<span onclick="' + pagerName + '.prevFirst();'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\',1);" class="linkWhite"> « First </span>';
			}
		}
		if($("#pg1").attr("class")=="pg-selected"||getCurrentTabData().pagerNumber==1){
			prevSet = "";
			prevSetAll = "";
		}
		var rowPagerHtml = "";
		var pagePagerHtml = "";
		var pagerHtml = "";
		if(getCurrentTabData().valueDateCheckin!=undefined&&getCurrentTabData().valueDateCheckin!="")
			rowPagerHtml = '<select id="Row'+pagerName+getCurrentTabData().resId+'" onChange="setRowPage(this.value);'+getCurrentTabData().functionGetData+'(\'dateSearch\','+page+');">'+RowpagerHtmlOption+'</select>';
		else
			rowPagerHtml = '<select id="Row'+pagerName+getCurrentTabData().resId+'" onChange="setRowPage(this.value);'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\','+page+');">'+RowpagerHtmlOption+'</select>';
		var pagerHtmlOption = "";
		
		for (var page = 1; page <= this.pages; page++){
			var rowSet = getCurrentTabData().rowSet;
			if(getCurrentTabData().valueDateCheckin!=undefined&&getCurrentTabData().valueDateCheckin!=""){
				pagerHtml += '<span id="pg' + page + '" style="color:#FFFF" class="linkWhite" onclick="' + pagerName + '.showPage(' + page + ');'+getCurrentTabData().functionGetData+'(\'dateSearch\','+page+');">' + page + '</span> ';
			}else{
				pagerHtml += '<span id="pg' + page + '" style="color:#FFFF" class="linkWhite" onclick="' + pagerName + '.showPage(' + page + ');'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\','+page+');">' + page + '</span> ';
			}	
			pagerHtmlOption += '<option  value="'+page+'">' + page + '</option> ';
		}
		if(this.pages==getCurrentTabData().pagerNumber||this.pages==1){
			nextSet = "";
			nextSetAll="";
		}else{
			if(getCurrentTabData().valueDateCheckin!=undefined&&getCurrentTabData().valueDateCheckin!=""){
				nextSet = '<span onclick="'+pagerName+'.next();'+getCurrentTabData().functionGetData+'(\'dateSearch\','+(parseInt(pagerNumber)+1)+');" class="linkWhite"> Next »</span>';
				nextSetAll = '<span onclick="' + pagerName + '.showPage(' + this.pages + ');'+getCurrentTabData().functionGetData+'(\'dateSearch\','+this.pages+');" class="linkWhite"> End »</span>';
			}else{
				nextSet = '<span onclick="'+pagerName+'.next();'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\','+(parseInt(pagerNumber)+1)+');" class="linkWhite"> Next »</span>';
				nextSetAll = '<span onclick="' + pagerName + '.showPage(' + this.pages + ');'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\','+this.pages+');" class="linkWhite"> Last »</span>';
			}
		}
		var pagePagerHtml = "";
		if(getCurrentTabData().valueDateCheckin!=undefined&&getCurrentTabData().valueDateCheckin!=""){
			pagePagerHtml = '<select id="'+pagerName+getCurrentTabData().resId+'" onChange="' + pagerName + '.showPage(this.value);'+getCurrentTabData().functionGetData+'(\'dateSearch\',this.value);">'+pagerHtmlOption+'</select>';
		}else{
			pagePagerHtml = '<select id="'+pagerName+getCurrentTabData().resId+'" onChange="' + pagerName + '.showPage(this.value);'+getCurrentTabData().functionGetData+'(\''+getCurrentTabData().pageName+'\',this.value);">'+pagerHtmlOption+'</select>';
		}
		if(this.pages==0)
			element.innerHTML = "";
		else{
			element.innerHTML = '<table width="100%"><tr class="trdataRecordBot"><td width="20%" class="spanDataCenter">Page '+pagePagerHtml+'of '+this.pages+'( '+getCurrentTabData().recordsPage+' total Records)</td>'+
			'<td width="20%" class="spanDataCenter">Showing '+rowPagerHtml+' Rows per page</td><td class="spanDataRight spanDataPaddingRight" width="80%">'+prevSetAll+prevSet+pagerHtml+nextSet+nextSetAll+
			'</td></tr></table>';
		}
		pagerHtml ="";
		//set row
		if(getCurrentTabData().optionValueCheckout!=undefined){
			$("#Rowpager"+getCurrentTabData().pageName).val(getCurrentTabData().optionValueCheckout);
		}
	}
}
function setRowPage(value){
	getCurrentTabData().optionValueCheckout = value;
}
function setPagePage(pageNumber){
	getCurrentTabData()["pagerNumber"] = pageNumber;
	getCurrentTabData()["rowSet"] = $("#Rowpager"+getCurrentTabData().pageName).val();
}